package vooga.entities;

import java.awt.Font;
import java.awt.font.TextLayout;


public class Text extends Entity
{
    private String myText = null;


    public Text (java.awt.geom.Point2D topLeft,
                 java.awt.geom.Dimension2D size,
                 String text)
    {
        super(topLeft, size,
              new java.awt.geom.Rectangle2D.Double(0, 0, 1, 1));
        myText = text;
    }

    protected void render (java.awt.Graphics2D layer)
    {
        Font font = layer.getFont();
        TextLayout layout = new TextLayout(myText, font, layer.getFontRenderContext());
//		float height = layout.getAscent() + layout.getDescent();
//		float width = layout.getAdvance();

	java.awt.Shape hilite = layout.getLogicalHighlightShape(0, myText.length());
	layer.setColor(getColor());
	layer.draw(hilite);

	layout.draw(layer, (float)getLeft(), (float)getRight());
    }

/*
    protected java.awt.geom.AffineTransform getTransform ()
    {
	// world is mapped to be upside-down, so re-flip text so it appears upright
        java.awt.geom.AffineTransform result = super.getTransform();
        result.scale(1, -1);
        return result;
    }
*/
}
